package com.xbongbong.parent.interfaces;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.ButtonPojo;
import com.xbongbong.paas.pojo.DataDetailPojo;
import com.xbongbong.paas.pojo.DetailTabPojo;
import com.xbongbong.paas.pojo.DetailTitlePojo;
import com.xbongbong.paas.pojo.HandelDetailPojo;
import com.xbongbong.paas.pojo.SummaryDataPoJo;
import com.xbongbong.paas.pojo.WorkFlowPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.pro.formdata.pojo.dto.FormDataDetailDTO;
import com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainDTO;
import com.xbongbong.pro.formexplain.pojo.vo.HandlerExplainVO;

import java.util.List;
import java.util.Map;

/**
 * web端 返回tab栏上班部分数据
 * @author 吴峰
 * @date 2021/12/22 20:52
 */
public interface BusinessWebDetailTopInfoService<T, D> {



    /**
     * saas详情头部按钮
     * ->com.xbongbong.saas.help.ProDetailHandlerHelp#handelDetailButton(com.xbongbong.paas.pojo.HandelDetailPojo)
     * @param formDataDetailDTO
     * @param handelDetailPojo
     * @param formData
     * @param explainMap
     * @return
     * @throws XbbException
     */
    List<ButtonPojo> handleDetailButton(FormDataDetailDTO formDataDetailDTO, HandelDetailPojo handelDetailPojo, D formData, Map<String, FieldAttrEntity> explainMap) throws XbbException;


    /**
     * saas头部关注按钮
     * ->com.xbongbong.saas.help.ProDetailHandlerHelp#handelDetailFocus(java.lang.Integer, com.xbongbong.paas.pojo.DetailTitlePojo, com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt, java.lang.String)
     * @param formDataDetailDTO
     * @param businessType
     * @param userId
     * @param paasFormDataEntityExt
     * @return
     * @throws XbbException
     */
    DetailTitlePojo handleDetailFocus(FormDataDetailDTO formDataDetailDTO, Integer businessType, D paasFormDataEntityExt, String userId) throws XbbException;


    /**
     * web端，返回关联新建
     * ->com.xbongbong.saas.help.ProDetailHandlerHelp#handelDetailWorkFlow(com.xbongbong.paas.pojo.HandelDetailPojo)
     * @param handelDetailPojo
     * @param formEntity
     * @param formData
     * @return
     * @throws XbbException
     */
    List<WorkFlowPojo> webHandleDetailWorkFlow(HandelDetailPojo handelDetailPojo, T formEntity, D formData) throws XbbException;




    /**
     * web端 处理详情页特殊返回，bom版本，跨月，分数
     * @param businessType
     * @param formData
     * @param userId
     * @param handlerExplainDTO
     * @return com.xbongbong.paas.pojo.DataDetailPojo
     * @author 吴峰
     * @date 2022/2/14 14:16
     * @throws XbbException
     */
    DataDetailPojo handleDetailData(Integer businessType, D formData, String userId, HandlerExplainDTO handlerExplainDTO) throws XbbException;

    /**
     * 处理特殊字段的解析
     * ->com.xbongbong.saas.help.ProDetailHandlerHelp#handleDetailSpecialField(com.alibaba.fastjson.JSONObject, java.lang.Long, java.lang.Integer, java.lang.String, java.util.Map, java.lang.Long, com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainDTO)
     * @param data
     * @param dataId
     * @param businessType
     * @param corpid
     * @param explainMap
     * @param formId
     * @param handlerExplainDTO
     * @return void
     * @author 吴峰
     * @date 2022/2/14 14:16
     * @throws XbbException
     */
    void handleDetailSpecialField(D formData, JSONObject data, Map<String, FieldAttrEntity> explainMap,  HandlerExplainDTO handlerExplainDTO) throws XbbException;
    /**
     * 获取摘要
     * @param formData
     * @param formDataDetailDTO
     * @param formEntity
     * @param list
     * @param data
     * @param explainMap
     * @return
     * @throws XbbException
     */
    JSONArray getSecondTitleList(FormDataDetailDTO formDataDetailDTO, D formData, T formEntity, List<FieldAttrEntity> list, Map<String, FieldAttrEntity> explainMap, JSONObject data) throws XbbException;

    /**
     * 获取标签
     * @param formData
     * @param formDataDetailDTO
     * @param formEntity
     * @param list
     * @param explainMap
     * @param data
     * @return
     * @throws XbbException
     */
    JSONArray getTagList(FormDataDetailDTO formDataDetailDTO, D formData, T formEntity, List<FieldAttrEntity> list, Map<String, FieldAttrEntity> explainMap, JSONObject data) throws XbbException;

    /**
     * 获取标题
     * @param formData
     * @param formDataDetailDTO
     * @param formEntity
     * @param list
     * @param explainMap
     * @param data
     * @return
     * @throws XbbException
     */
    String getTitle(FormDataDetailDTO formDataDetailDTO, D formData, T formEntity, List<FieldAttrEntity> list, Map<String, FieldAttrEntity> explainMap, JSONObject data) throws XbbException;

    /**
     * 获取每个摘要的子项
     * 机会、应收款、付款计划，需要单独实现，其他都在父类中实现
     * ->com.xbongbong.saas.help.ProDetailHandlerHelp#handelDetail(java.lang.Integer, java.lang.Long, com.alibaba.fastjson.JSONObject, java.lang.Integer, java.util.Map, com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt, java.lang.String, java.lang.Long, com.alibaba.fastjson.JSONArray, com.alibaba.fastjson.JSONArray, com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt, java.util.List, com.xbongbong.paas.pojo.DetailTitlePojo, java.lang.Integer, java.lang.String)
     * 抽离于上述方法2212行至2290行
     * @param pojo
     * @param value
     * @param data
     * @param corpid
     * @param formId
     * @return
     */
    JSONObject getSecondTitle(SummaryDataPoJo pojo, Object value, JSONObject data, String corpid, Long formId);
    /**
     * 获取tab列表
     * ->com.xbongbong.saas.help.ProDetailHandlerHelp#handelDetailTab(com.xbongbong.paas.pojo.HandelDetailPojo, com.xbongbong.paas.enums.PlatFormEnum, java.util.Map, java.lang.Integer)
     * @param handelDetailPojo
     * @param formEntity
     * @param formData
     * @param explainMap
     * @param handlerExplainVO
     * @param handlerExplainDTO
     * @return java.util.List<com.xbongbong.paas.pojo.DetailTabPojo>
     * @author 吴峰
     * @date 2022/2/11 15:51
     * @throws XbbException
     */
    List<DetailTabPojo> handleDetailTab(HandelDetailPojo handelDetailPojo, T formEntity, D formData, Map<String, FieldAttrEntity> explainMap, HandlerExplainVO handlerExplainVO, HandlerExplainDTO handlerExplainDTO) throws XbbException;

    
    /**
     * 处理标签
     * @param formDataDetailDTO
     * @param formEntity
     * @param tags
     * @param paasFormDataEntityExt
     * @param explainMap
     * @return java.lang.String
     * @author 吴峰
     * @date 2022/2/11 19:11
     * @throws XbbException       
     */
    String dealWebDetailLabelListLocation(FormDataDetailDTO formDataDetailDTO, T formEntity, JSONArray tags, D paasFormDataEntityExt, Map<String, FieldAttrEntity> explainMap) throws XbbException;




}
